package com.ph.irp.base.verifyproject.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ph.exception.PHException;
import com.ph.irp.base.verifyproject.dao.PBaseVerifyprogectCashDao;
import com.ph.irp.base.verifyproject.service.PBaseVerifyprojectCashService;
import com.ph.irp.model.PBaseVerifyprojectCashrunoff;

/**
 * The Class PBaseVerifyprojectCashServiceImpl.
 * 
 * @author SongYandong song.yandong@phinfoservices.com
 * @version 1.0 <br>
 *          Copyright (C), 2009, SongYandong <br>
 *          This program is protected by copyright laws. <br>
 *          Program Name: PBaseVerifyprojectCashServiceImpl.java<br>
 *          Date:2009-11-12
 */
public class PBaseVerifyprojectCashServiceImpl implements
		PBaseVerifyprojectCashService {

	/** The cash dao. */
	private PBaseVerifyprogectCashDao cashDaoProxy;

	public PBaseVerifyprogectCashDao getCashDaoProxy() {
		return cashDaoProxy;
	}

	public void setCashDaoProxy(PBaseVerifyprogectCashDao cashDaoProxy) {
		this.cashDaoProxy = cashDaoProxy;
	}

	/**
	 * 添加方法
	 * 
	 */
	@Override
	public void addCash(PBaseVerifyprojectCashrunoff model) throws Throwable {
		cashDaoProxy.addCash(model);

	}

	/**
	 * 删除方法
	 */
	@Override
	public int deleteCash(Object[] id) throws Throwable {
		for (int i = 0; i < id.length; i++) {
			try {
				System.out.println("print:" + id[i]);
				cashDaoProxy.deleteCash(Integer.valueOf((String) id[i]));
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new Throwable("项目已经被其他条目引用，不能删除，请确认后操作");
			}

		}
		return 0;
	}

	/**
	 * 查询方法
	 */
	@Override
	public List<PBaseVerifyprojectCashrunoff> getAllCash() throws Throwable {
		return cashDaoProxy.getAllCash();
	}

	/**
	 * 根据ID查询方法
	 */
	@Override
	public PBaseVerifyprojectCashrunoff getCashById(int id) throws Throwable {
		return cashDaoProxy.getCashById(id);
	}
	
	public  List<PBaseVerifyprojectCashrunoff> getCashByCodeAndName(PBaseVerifyprojectCashrunoff model) throws Throwable{
		return cashDaoProxy.getCashByCodeAndName(model);
	}

	/**
	 * 修改方法
	 */
	@Override
	public void updateCash(PBaseVerifyprojectCashrunoff model) throws Throwable {
		cashDaoProxy.updateCash(model);
	}

}
